import {url,axios} from '.';

export const getFunctionById = async (id) => {
    let res = await axios({
        method: 'get',
        url: `${url}/functions/${id}`
    });
    return res.data;
}

export const listFunction = async (current,pageSize) => {
    let res = await axios({
        method: 'get',
        url: `${url}/functions`,
        params: {
            current,pageSize
        }
    });
    return res.data;
}




export const addFunction = async (func) => {
    let res = await axios({
        method: 'post',
        url: `${url}/functions`,
        data:{...func}
    });
    return res.data;
}

export const updateFunction = async (func) => {
    let res = await axios({
        method: 'put',
        url: `${url}/functions/${func.id}`,
        data:{...func}
    });
    return res.data;
}

export const deleteFunction = async (id) => {
    let res = await axios({
        method: 'delete',
        url: `${url}/functions/${id}`
    });
    return res.data;
}